package br.edu.utfpr.backuptools.BackupTools.util.worker;

import javax.swing.SwingWorker;

import br.edu.utfpr.backuptools.BackupTools.controller.validator.RetornoValidacao;
import br.edu.utfpr.backuptools.BackupTools.model.pojo.Backup;
import br.edu.utfpr.backuptools.BackupTools.view.action.AbstractAction;
import br.edu.utfpr.backuptools.BackupTools.view.action.backup.GerarBackupIndividual;
import br.edu.utfpr.backuptools.BackupTools.view.action.backup.GerarTodosBackups;

/**
 * Worker responsável por fazer um backup individual e geral
 * 
 * @author Luan Malaguti Reffatti
 *
 */
public class WorkerBackup extends SwingWorker<Void, Void> {
	
	Backup backup;
	RetornoValidacao rv;
	
	public WorkerBackup(Backup backup)
	{
		this.backup = backup;
	}
	
	@Override
	protected Void doInBackground() throws Exception
	{
		if(backup == null){
			AbstractAction<Backup> actionGerarBackups = new GerarTodosBackups();
			rv = actionGerarBackups.execute(null);
		}
		else{
			AbstractAction<Backup> action = new GerarBackupIndividual();
			action.execute(backup);
		}
		return null;
	}
	
	public RetornoValidacao getRv(){
		return rv;
	}

}